-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RTG] Add ElaborationPass #7876
Conversation
36dfd4c
to
2633cab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will keep looking tomorrow, its looking great! 😁
// If the test requries nothing from a target, we can always run it. | ||
if (test.getTarget().getEntryTypes().empty()) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if a test does not have any requirements we won't run it on each target, just once in general?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two things to consider:
- The unelaborated test is the same for all targets, so do we want to randomize it once for each target or randomize it once and use that for each target? If the latter, then we don't have to copy it. But I guess the earlier approach would be the more consistent one, right?
- Currently I assume that all tests for all targets will be run on the same system because there is no way to distinguish them after this pass. If we want to have targets for different systems in the same MLIR file, we'd need some scoping, add the target that the test specialized for as an attribute, or some other way to distinguish them. As long as we don't do that, we don't need to duplicate a test that has the same content.
I guess I will change it to be copied and independently randomized for each target, but leave point 2 for a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really know whats best, what you had originally is probably good! We can revisit these points in the future easily enough.
506937f
to
14a434c
Compare
2633cab
to
b89ad7c
Compare
b89ad7c
to
df7c685
Compare
df7c685
to
f8cb26a
Compare
07d1ea4
to
07d7892
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I have removed handling of sequences to simplify this PR and will create another PR with those features. Support for sequences is far from trivial and having them in another PR allows us to focus on sets in this PR.
- I've removed opaque/unevaluated values for now and will also add them in a future PR such that we can focus on the issues that this can introduce in a dedicated PR
- I've added an
AttributeValue
to be able to add tests now that we don't support sequences anymore (this is easier to reason about and we need it anyway) - I've fixed the dominance issues by introducing a materializer that properly caches materialized values per block and by removing opaque value support for now
- I've fixed an issue where I iterated over a non-deterministic set order. Basically we need to keep track of some deterministic order for sets in general not just in debug mode. Thus I replaced it with a SetVector.
- Removed the
rtg.elaboration
attribute support in favour ofrtg.elaboration_custom_seed
with specifies a seed just for that particular op and removed debug mode. Being able to specify the index in the set is more complicated to handle for not a lot of benefit. The purpose for the attribute is to make it easier to write tests (adding a test at some point should not influence the random selection at another place). - I've added some additional debug printing support for which I had a separate PR, but I think it's valuable to have it from the start and it also included some bug fixes.
template <typename ValueTy, typename... Args> | ||
void internalizeResult(Value val, Args &&...args) { | ||
// TODO: this isn't the most efficient way to internalize | ||
auto ptr = std::make_unique<ValueTy>(std::forward<Args>(args)...); | ||
auto *e = ptr.get(); | ||
auto [iter, _] = interned.insert({e, std::move(ptr)}); | ||
state[val] = iter->second.get(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't updated the internalization logic to a more efficient approach yet. My strategy would be to wait until we have a big input example that we can use the profile this part to find the most efficient implementation. But let me know if you would like to see an improvement already in this PR.
// inserting an object of a derived class of ElaboratorValue. | ||
// The custom MapInfo makes sure that we do a value comparison instead of | ||
// comparing the pointers. | ||
DenseMap<ElaboratorValue *, std::unique_ptr<ElaboratorValue>, InternMapInfo> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you pointed out yesterday, this is not particularly elegant. The reason I did it that way is because unique pointers don't seem to work as set or map keys because the copy constructor is deleted. Maybe I'm just missing something to make this work?
Alternatively, we could just use raw pointers that we deallocate manually in the destructor, but that's not very elegant either.
Any concrete suggestions on how to improve this?
9f88cb6
to
f9c513a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% familiar with the details of the RTG dialect, but the implementation makes sense to me 👍
f9c513a
to
505d2a0
Compare
505d2a0
to
999992a
Compare
Add a pass that lowers the random parts of RTG IR.